<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>2.5.5箭头函数</title>
    </head>
    <body>
        <script>
            //【例2.36】箭头函数1
            function Counter(){
                this.num = 0;
                this.timer = setInterval(function add(){
                    this.num++;
                    console.log(this.num);
                },1000);
            }
            var a=new Counter();

            //【例2.37】箭头函数2
            function Counter(){
                this.num = 0;
                this.timer = setInterval(()=>{
                    this.num++;
                    console.log(this.num);
                },1000);
            }
            var a=new Counter();

            //和一般函数不同，箭头函数不会绑定this.
        </script>
    </body>
</html>